Announcement

Collapse
No announcement yet.

Plotting today’s data tomorrow

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Plotting today’s data tomorrow

    The attached study plots the date (see green square in picture) correctly over the first bar of each day but I would like for it to plot on the first bar of the next day. In other words, if today is the 24th then on the first bar of today the plot would be data for the 23rd.

    Any help would be appreciated.

    Wayne

    PHP Code:
    function preMain(){
        
    setPriceStudy(true);
    }
    function 
    main(){
        var 
    xTime getValue("time");
        var 
    xFstBarIndxDay getFirstBarIndexOfDay(xTime);
        var 
    xDate xTime.getDate();

        if(
    getBarState() == BARSTATE_NEWBAR) {
            
    drawShapeAbsolutexFstBarIndxDayclose(0), Shape.SQUARE nullColor.RGB(31,200,19), Shape.TOP Shape.ONTOP );
            
    drawTextAbsolutexFstBarIndxDayclose(0), xDateColor.yellowColor.RGB(31,200,19), Text.ONTOP Text.CENTER"Courier New");
        }

    Attached Files
    Last edited by waynecd; 02-27-2011, 09:36 AM.

  • #2
    PHP Code:
    //"vIndex" is null for current day since there is no "next" day
    debugClear();
    function 
    preMain(){
        
    setPriceStudy(true);
    }
    function 
    main(){
        var 
    vTime,today,xDate,tIndex,vNextDay,vIndex;
        
    vTime getValue("rawtime");
        
    today = new Date(vTime*1000);
        
    xDate today.getDate();//debugPrintln("7: "+today);
        
    if (vTime != null) {
            
    tIndex getFirstBarIndexOfDay(vTime);
            
    vNextDay getNextTradingDayvTime );
            if (
    vNextDay != null) {
                
    vIndex getFirstBarIndexOfDayvNextDay );
            }
        }
    debugPrintln("\ntoday: "+today+"\nvIndex"+vIndex+"\ntIndex"+tIndex+"\nvNextDay: "+vNextDay+"\nvIndex: "+vIndex);
            
    drawShapeAbsolute( (vIndex+1), close(0), Shape.SQUARE nullColor.RGB(31,200,19), Shape.TOP Shape.ONTOP );
            
    drawTextAbsolute( (vIndex+1), close(0), xDateColor.yellowColor.RGB(31,200,19), Text.ONTOP Text.CENTER"Courier New");
        return 
    vIndex+"";

    Comment

    Working...
    X